<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
?><div class="user-body">
  	<div class="body-content">
  	  <div class="tab-box">
      		<a href="<?php echo site_url('push_manage/index');?>?type=0" 
<?php
if ($type == 0) {
?>class="on"<?php
}

?>>发起求购信息</a>
      		<a href="<?php echo site_url('push_manage/index');?>?type=1" 
<?php
if ($type == 1) {
?>class="on"<?php
}

?>>发布PUSH</a>
      	</div>
      <div class="money-form">
     	<form action="<?php echo site_url('push_manage/insert');?>" method="post" id="form_id">
     	<input type="hidden" name="type" value="<?php echo $type;?>">
      	<table cellspacing=0 cellpadding=0 border=0>
      		<tr><th>币种：</th>
	      		<td>
		      		<select name="coin_id">
			      		
<?php
foreach ($coins as $v) {
?>			      		<option value="<?php echo $v['id'];?>"><?php echo $v['cn_name'];?></option>
			      		<?php
}

?>		      		</select>
	      		</td>
      		</tr>
      		
<?php
if ($type == 1) {
?>      		<tr><th>接收方UID：</th><td><input type="text" name="to_uid"><p>请输入接收方UID</p></td></tr>
      		<!-- <tr><th>接收方姓名：</th><td><input type="text" name="to_name"><p>请输入接收方姓名</p></td></tr> -->
      		<?php
}

?>      		<tr><th>数量：</th><td><input type="text" name="amount" must="1"><p>请输入转币数量</p></td></tr>
      		<tr><th>单价：</th><td><input type="text" name="price" must="1" style="width:150px;"><p>请输入单价</p>
      			<select name="price_coin_id" style="width:106px;">
		      		
<?php
foreach ($coins as $v) {
?>		      		<option value="<?php echo $v['id'];?>"><?php echo $v['cn_name'];?></option>
		      		<?php
}

?>	      		</select>
		      	</td>
		    </tr>
      		<tr><th>总金额：</th><td><input type="text" name="total" must="1" readonly><p>请输入总金额</p></td></tr>
      		<tr><th>安全密码：</th><td><input type="password" name="paypwd" must="1"><p>请输入安全密码</p></td></tr>
      		<tr><th></th><td class="warning"></td></tr>
      		<tr><th></th><td><button type="submit"><?php echo lang('money_next');?></button></td></tr>
      	</table>
      	</form>
      </div>
     
      <script>
		$(function(){
			$('#form_id').checkForm();
			$('[name="amount"],[name="price"]').bind('change keyup',function(d){
				var amount = $('[name="amount"]').val();
				var price = $('[name="price"]').val();
				$('[name="total"]').val(Number(amount)*Number(price));
			});
		})
      </script>
      
      <div class="list">
      	<div class="tab-box">
      		<a href="<?php echo site_url('push_manage/index');?>?flag=0" 
<?php
if ($flag == 0) {
?>class="on"<?php
}

?>>发起的PUSH</a>
      		<a href="<?php echo site_url('push_manage/index');?>?flag=1" 
<?php
if ($flag == 1) {
?>class="on"<?php
}

?>>收到的PUSH</a>
      	</div>
      	<table cellspacing=0 cellpadding=0 border=0>
			<thead>
				<tr>
					<th>币种</th>
					<th>数量</th>
					<th>总金额</th>
					<th>对方联系方式</th>
					<th>时间</th>
					<th>状态</th>
					
<?php
if ($flag == 1) {
?><th>操作</th><?php
}

?>				</tr>
			</thead>
			<tbody>
			    
<?php
foreach ($list as $v) {
?>				<tr>
					<td><?php echo $v['coin']['cn_name'];?></td>
					<td><?php echo $v['amount'];?></td>
					<td><?php echo $v['total'];?></td>
					<td><?php echo $v['to_name'];?> / <?php echo $v['to_uid'];?></td>
					<td><?php echo date('Y-m-d H:i', $v['add_time']);?></td>
					<td>
						
<?php
	if ($v['status'] == 0) {
?>进行中<?php
	}

?>						
<?php
	if ($v['status'] == 1) {
?>已完成<?php
	}

?>					</td>
					
<?php
	if ($flag == 1) {
?><td><a data-id="<?php echo $v['id'];?>" class="push-get">接收</a></td><?php
	}

?>				</tr>
				<?php
}

?>			</tbody>
		</table>
		<div class="page">
		  <?php echo $page;?>		</div>
		
<?php
if (!$list) {
?>		<div class="not-list">
			<i class="fa fa-ban"></i>
			<span><?php echo lang('user_not_list');?></span>
		</div>
		<?php
}

?>		<div class="clear"></div>
      </div>
    </div>
  </div>
  <div class="clear"></div>
</div>
<script>
$(function(){
	$('.push-get').single('<?php echo site_url('push_manage/trade');?>');
	$('#status').change(function(){
		$.cookie('select_status',$(this).val());
		location.reload();
	});
	
});
</script>